using System;
using System.IO;
using System.Reflection;
using System.Text.RegularExpressions;

namespace csdeps
{
	class Class1
	{
		static Regex[] exclusionList = {
											new Regex("^mscorlib\\.dll$"),
											new Regex("^System$"),
											new Regex("^System\\.")
		};

		static void DumpAssemblyDeps(string path, string assemblyName, int depth)
		{
			string space = new string(' ', depth * 2);
			Console.Write(space + assemblyName);

			foreach (Regex r in exclusionList)
			{
				if (r.IsMatch(assemblyName))
				{
					Console.WriteLine("");
					return;
				}
			}

			string fullpath = path + "\\" + assemblyName;

			if (!File.Exists(fullpath))
			{
				Console.WriteLine(" -- not found");
				return;
			}
			else
			{
				Console.WriteLine("");
			}


			Assembly a = Assembly.LoadFile(fullpath);

			AssemblyName[] names = a.GetReferencedAssemblies();
			foreach (AssemblyName name in names)
			{
				DumpAssemblyDeps(path, name.Name + ".dll", depth + 1);
			}
		}

		static int Main(string[] args)
		{
			if (args.Length < 1)
			{
				Usage();
				return 1;
			}

			DumpAssemblyDeps(Path.GetDirectoryName(Path.GetFullPath(args[0])), Path.GetFileName(args[0]), 0);

			return 0;
		}
		
		static void Usage()
		{
		}
	}
}
